package cn.lx.log.core.context;

import cn.lx.log.core.entity.CurrentUser;

import java.util.HashMap;
import java.util.Map;

public class UserContextImpl implements UserContext {

    private static final long serialVersionUID = 8383356012441014698L;
    /**
     * 当前用户信息
     */
    private CurrentUser currentUser = new CurrentUser();
    /**
     * 上下文属性Map
     */
    private Map properties = new HashMap();

    public UserContextImpl() {
    }

    @Override
    public CurrentUser getCurrentUser() {
        return this.currentUser;
    }

    @Override
    public void setCurrentUser(CurrentUser currentUser) {
        this.currentUser = currentUser;
    }

    @Override
    public void removeCurrentUser() {
        this.currentUser = null;
    }

    @Override
    public Object getProperty(Object key) {
        return this.properties.get(key);
    }

    @Override
    public void addProperty(Object key, Object value) {
        this.properties.put(key, value);
    }

    @Override
    public void removeProperty(Object key) {
        this.properties.remove(key);
    }

    @Override
    public Map getProperties() {
        return this.properties;
    }

    @Override
    public void setProperties(Map map) {
        this.properties = map;
    }

    @Override
    public void removeAllProperties() {
        this.properties.clear();
    }

}
